$caret-width: .3em !default;
$caret-vertical-align: $caret-width * .85 !default;
$caret-spacing: $caret-width * .85 !default;

@mixin caret-down() {
    border-top: $caret-width solid;
    border-right: $caret-width solid transparent;
    border-bottom: 0;
    border-left: $caret-width solid transparent;
}

@mixin caret-up() {
    border-top: 0;
    border-right: $caret-width solid transparent;
    border-bottom: $caret-width solid;
    border-left: $caret-width solid transparent;
}

@mixin caret-right() {
    border-top: $caret-width solid transparent;
    border-right: 0;
    border-bottom: $caret-width solid transparent;
    border-left: $caret-width solid;
}

@mixin caret-left() {
    border-top: $caret-width solid transparent;
    border-right: $caret-width solid;
    border-bottom: $caret-width solid transparent;
}

@mixin caret($direction: down) {
    &::after {
        display: inline-block;
        margin-left: $caret-spacing;
        vertical-align: $caret-vertical-align;
        content: "";

        @if $direction == down {
            @include caret-down();
        }
        @else if $direction == up {
            @include caret-up();
        }
        @else if $direction == right {
            @include caret-right();
        }
    }

    @if $direction == left {
        &::after {
            display: none;
        }

        &::before {
            display: inline-block;
            margin-right: $caret-spacing;
            vertical-align: $caret-vertical-align;
            content: "";
            @include caret-left();
        }
    }

    &:empty::after {
        margin-left: 0;
    }
}

@mixin navbar-v-popout-menu-container {
    z-index: calc(var( --navbar-v-zindex, 1110) + 1);
    max-height: 30vh;
    position: absolute;
    margin: -42px 5px 0px 5px;
    display: flex;
    width: var( --navbar-v-popout-menu-width, 180px);
}

@mixin navbar-v-popout-menu {
    box-shadow: 0 3px 6px -4px rgba(0,0,0,.12), 0 6px 16px 0 rgba(0,0,0,.08), 0 9px 28px 8px rgba(0,0,0,.05);
    border-radius: 3px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1 100%;

    .navbar-v-dropdown-item {
        padding: .5rem .5rem .5rem 1.5rem;
    }

    &:before {
        position: absolute;
        top: 0;
        left: -7px;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        opacity: .0001;
        content: ' ';
        z-index: -1;
    }

    &.navbar-v-right {
        &:before {
            left: unset;
            right: -7px;
        }
    }
}

@mixin navbar-v-dropdown-arrow {
    content: " ";
    border: solid;
    display: inline-block;
    padding: 2px;
    transition: transform 200ms ease-out;
    position: relative;
}

/* 初始状态 */
.navbar-initial {
    display: none !important;
}

.navbar {
    .nav-item {
        position: relative;
    }

    .navbar-nav .nav-item:hover {
        cursor: pointer;
    }

    .navbar-nav .nav-link:hover {
        cursor: pointer;
    }

    .nav .nav-link:hover {
        cursor: pointer;
    }

    .navbar-icon {
        transition: transform .3s linear;
    }
}

/* 水平菜单 */
.navbar-h-topbar {
    &[data-collapse=hide] {
        flex-wrap: nowrap;

        &[data-broken=true] {
            height: auto;
        }
    }

    &[data-broken=false] {
        height: auto;
    }

    .widget .dropdown-toggle,
    .dropdown-logout .dropdown-toggle {
        color: inherit;
    }

    .nav-item.dropdown {
        .dropdown-menu {
            > .dropdown {
                > .dropdown-item {
                    width: 100%;

                    @include caret();

                    &::after {
                        transform: rotate( -90deg);
                        position: absolute;
                        right: 10%;
                        top: 45%;
                    }
                }

                > .dropdown-menu {
                    top: 0;
                    left: 100%;
                    margin-left: 0rem;
                    margin-right: .1rem;
                }
            }
        }

        > .navbar-h-dropdown-menu:after {
            content: " ";
            width: 0;
            height: 0;
            border-width: 0 6px 6px;
            border-style: solid;
            border-color: transparent transparent #fff;
            position: absolute;
            top: -6px;
            left: 18px;
        }
    }

    .dropdown:hover {
        > .navbar-h-dropdown-menu {
            display: block;
        }
    }

    .navbar-h-dropdown:not(.nav-item) {
        &:hover, &.show {
            > .dropdown-item {
                color: #1e2125;
                background-color: #e9ecef;
            }
        }
    }
    // 深色主题
    &.navbar-dark {
        background: var( --navbar-v-dark-background, #001529) !important;
        color: var( --navbar-v-dark-color, rgba(255,255,255, 0.5)) !important;

        .navbar-brand {
            background: var( --navbar-v-brand-dark-background, rgba(255,255,255,0.025));

            .navbar-link {
                color: #fff;

                &.active {
                    color: #fff;
                    background: inherit;
                }

                &:hover {
                    color: #fff;
                    background: inherit;
                }
            }
        }

        .navbar-link {
            color: inherit;

            &.active {
                color: var( --navbar-v-item-dark-active-color, #fff);
                background: var( --navbar-v-item-dark-active-background, #0288D1);
            }

            &:hover {
                color: var( --navbar-v-item-dark-hover-color, #fff);
                background: var( --navbar-v-item-dark-hover-background, rgba(255,255,255,0.3));
            }
        }
    }
    // 浅色主题
    &.navbar-light {
        background: var( --navbar-v-light-background, #fff);
        color: var( --navbar-v-light-color, rgba(0,0,0,0.7));

        .navbar-brand {
            background: var( --navbar-v-brand-light-background, rgba(0,0,0,0.025));

            .navbar-link {
                color: #000;

                &.active {
                    background: inherit;
                }

                &:hover {
                    background: inherit;
                }
            }
        }

        .navbar-link {
            color: inherit;

            &.active {
                color: var( --navbar-v-item-light-active-color, #000);
                background: var( --navbar-v-item-light-active-background, #0288D1);
            }

            &:hover {
                color: var( --navbar-v-item-light-hover-color, #000);
                background: var( --navbar-v-item-light-hover-background, rgba(0,0,0,0.3));
            }
        }
    }
}

/* 垂直菜单 默认样式 */
.navbar-v-inline,
.navbar-v-popout,
.navbar-v-small {
    z-index: var( --navbar-v-zindex, 1110);
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    position: sticky;
    top: 0;
    padding: 0;
    min-width: var( --navbar-v-width, 230px);
    max-width: var( --navbar-v-width, 230px);
    width: var( --navbar-v-width, 230px);

    &:not(.navbar-initial) {
        transition: width 200ms ease-in-out, min-width 200ms ease-in-out;
    }

    box-shadow: 2px 0 6px rgba(0,21,41,.35);
    height: 100%;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;

    .navbar-v-menu {
        width: 100%;
        display: flex;
        flex: 1;
        justify-content: space-between;
        flex-direction: column;
        align-self: stretch;
        /*屏蔽滚动条*/
        height: 100%;
        scrollbar-width: none;
        -ms-overflow-style: none;
        overflow: auto;

        &::-webkit-scrollbar {
            display: none;
        }
    }

    .navbar-v-brand {
        width: 100%;
        display: flex;
        height: var( --navbar-v-brand-height, 64px);
        min-height: var( --navbar-v-brand-height, 64px);
    }

    .navbar-v-toggler-inline {
        height: var( --navbar-v-brand-height, 64px);
        padding: 12px;
        display: inline-flex;
        cursor: pointer;
        position: absolute;
        right: 0;

        & > * {
            margin: auto;
        }
    }

    .navbar-v-toggler-popout:not(.navbar-v-mobile-toggle) {
        display: flex;
        position: fixed;
        left: var( --navbar-v-width, 230px);
        border-radius: 0px 10px 10px 0px;
        border: 0px;
        width: 10px;
        height: 40px;
        padding: 5px;
        align-items: center;

        &:not(.navbar-initial) {
            transition: width 200ms ease-in-out, left 200ms ease-in-out;
        }

        box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35);
        cursor: pointer;

        & > * {
            margin: auto;
            display: none;
        }

        &:hover {
            width: 45px;

            & > * {
                display: block;
            }
        }
    }

    .navbar-v-item {
        margin: auto;
        flex-grow: 1;
        min-height: 40px;

        .navbar-icon {
            font-size: 1.25rem;
            vertical-align: middle;
            margin: 3px;
            display: inline-block;
        }
    }

    .navbar-v-start {
        width: 100%;
        display: block;
    }

    .navbar-v-end {
        padding-bottom: 1rem;
        width: 100%;
        padding-top: 1rem;
        display: block;
    }

    .navbar-v-link {
        display: block;
        width: 100%;
        text-decoration: none;
        padding: .5rem .5rem .5rem 1.5rem;
        cursor: pointer;
        overflow-x: hidden;
        line-height: 1.5rem;
        vertical-align: middle;
        transition: font-size 150ms ease-in;
    }

    .navbar-v-link, .navbar-v-dropdown-item {
        .navbar-dropdown-widget {
            float: right;
            margin: 0 2rem;
        }
    }

    .navbar-v-label {
        background: transparent;
        color: #adb5bd;
        padding: .375rem 1.25rem;
        font-size: .75rem;
        text-overflow: ellipsis;
        overflow-x: hidden;
    }

    .navbar-v-dropdown {
        .navbar-v-dropdown-menu {
            display: none;
            background: inherit;
            color: inherit;
            float: none;
            padding: 5px 0px;
            scrollbar-width: none;
            -ms-overflow-style: none;

            &[data-visible=true] {
                display: block;
            }

            .navbar-v-dropdown-item {
                position: relative;
                color: inherit;
                transition: background 100ms ease-in-out,color 100ms ease-in-out;
                text-decoration: none;
                display: block;
                width: 100%;
                overflow-x: hidden;

                i {
                    margin-right: 0.3rem;
                }
            }

            &:before {
                background: inherit;
                box-shadow: none;
            }

            &::-webkit-scrollbar {
                display: none;
            }
            /* 滚动指示器 */
            > .navbar-track {
                position: absolute;
                z-index: calc(var( --navbar-v-zindex, 1110) + 2);
                pointer-events: none;
                width: 2px;
                height: 100%;
                top: 0;
                right: 5px;

                > .navbar-thumb {
                    position: absolute;
                    background-color: #1890ff;
                    width: 2px;
                }
            }
        }
    }

    .navbar-v-mobile-toggle {
        right: 20px;
        margin: auto;
        display: none;
    }

    // 支持多行截断
    .navbar-v-item-multi-line {
        display: -webkit-box !important;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: var( --navbar-v-item-lines, 2);
        white-space: normal !important;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    // 深色主题
    &.navbar-dark {
        background: var( --navbar-v-dark-background, #001529);
        color: var( --navbar-v-dark-color, rgba(255,255,255, 0.5));

        .navbar-v-brand {
            background: var( --navbar-v-brand-dark-background, rgba(255,255,255,0.025));

            .navbar-v-link {
                color: #fff;

                &.active {
                    color: #fff;
                    background: inherit;
                }

                &:hover {
                    color: #fff;
                    background: inherit;
                }
            }
        }

        .navbar-v-toggler-popout:not(.navbar-v-mobile-toggle) {
            background: var( --navbar-v-dark-background, #001529);
            color: var( --navbar-v-dark-color, rgba(255, 255, 255, 0.5));
        }

        .navbar-v-dropdown-menu {
            background: var( --navbar-v-dropdown-dark-background, #000c17);

            .navbar-v-dropdown-item {
                &.active {
                    color: var( --navbar-v-item-dark-active-color, #fff);
                    background: var( --navbar-v-item-dark-active-background, #0288D1);
                }

                &:hover {
                    color: var( --navbar-v-item-dark-hover-color, #fff);
                    background: var( --navbar-v-item-dark-hover-background, rgba(255,255,255,0.3));
                }
            }
        }

        .navbar-v-link {
            color: inherit;

            &.active {
                color: var( --navbar-v-item-dark-active-color, #fff);
                background: var( --navbar-v-item-dark-active-background, #0288D1);
            }

            &:hover {
                color: var( --navbar-v-item-dark-hover-color, #fff);
                background: var( --navbar-v-item-dark-hover-background, rgba(255,255,255,0.3));
            }
        }
    }
    // 浅色主题
    &.navbar-light {
        background: var( --navbar-v-light-background, #fff);
        color: var( --navbar-v-light-color, rgba(0,0,0,0.7));

        .navbar-v-brand {
            background: var( --navbar-v-brand-light-background, rgba(0,0,0,0.025));

            .navbar-v-link {
                color: #000;

                &.active {
                    background: inherit;
                }

                &:hover {
                    background: inherit;
                }
            }
        }

        .navbar-v-toggler-popout:not(.navbar-v-mobile-toggle) {
            background: var( --navbar-v-brand-light-background, #fff);
            color: var( --navbar-v-light-color, rgba(0,0,0,0.7));
        }

        .navbar-v-dropdown-menu {
            background: var( --navbar-v-dropdown-light-background, #f2f2f2);

            .navbar-v-dropdown-item {
                &.active {
                    color: var( --navbar-v-item-light-active-color, #000);
                    background: var( --navbar-v-item-light-active-background, #0288D1);
                }

                &:hover {
                    color: var( --navbar-v-item-light-hover-color, #000);
                    background: var( --navbar-v-item-light-hover-background, rgba(0,0,0,0.3));
                }
            }
        }

        .navbar-v-link {
            color: inherit;

            &.active {
                color: var( --navbar-v-item-light-active-color, #000);
                background: var( --navbar-v-item-light-active-background, #0288D1);
            }

            &:hover {
                color: var( --navbar-v-item-light-hover-color, #000);
                background: var( --navbar-v-item-light-hover-background, rgba(0,0,0,0.3));
            }
        }

        .navbar-menu:after {
            border-right-color: var( --navbar-v-item-light-hover-background, rgba(0,0,0,0.3));
        }


        .navbar-thumb {
            background-color: var( --navbar-v-item-light-hover-background, rgba(0,0,0,0.3)) !important;
        }
    }
    /* 滚动指示器 */
    .navbar-menu {
        --navbar-menu-scroll-top: 0;
        --navbar-menu-scroll-height: 0;
        --navbar-menu-scroll-display: none;

        &:after {
            content: "";
            position: absolute;
            pointer-events: none;
            width: 100%;
            top: var(--navbar-menu-scroll-top,0);
            height: var(--navbar-menu-scroll-height,0);
            display: var(--navbar-menu-scroll-display,0);
            transition: width .3s linear,left .3s linear;
            bottom: 0;
            border-right: 2px solid #1890ff;
        }
    }
}

/* 垂直菜单 折叠浮动模式 */
.navbar-v-small,
.navbar-v-inline[data-collapse=small],
.navbar-v-popout[data-collapse=small] {
    width: var( --navbar-v-small-width, 80px);
    min-width: var( --navbar-v-small-width, 80px);

    &:not(.navbar-initial) {
        transition: width 200ms ease-in-out, min-width 200ms ease-in-out;
    }

    .navbar-v-toggler-inline {
        position: relative;
        width: 100%;
    }

    .navbar-v-toggler-popout:not(.navbar-v-mobile-toggle) {
        left: var( --navbar-v-small-width, 80px);
    }

    .navbar-v-item {
        > .navbar-v-dropdown {
            > .navbar-v-dropdown-toggle {
                &:before {
                    display: none!important;
                }
            }
        }
    }

    .navbar-v-dropdown {
        .navbar-v-dropdown-menu-container {
            @include navbar-v-popout-menu-container;
            left: var( --navbar-v-small-width, 80px);

            &.navbar-v-right {
                right: var( --navbar-v-small-width, 80px);
                left: unset;
            }

            .navbar-v-dropdown-menu {
                @include navbar-v-popout-menu;

                > .navbar-v-dropdown {
                    .navbar-v-dropdown-menu-container {
                        left: var( --navbar-v-popout-menu-width, 180px);

                        &.navbar-v-right {
                            right: var( --navbar-v-popout-menu-width, 180px);
                        }
                    }
                }
            }

            &.navbar-v-floating {
                left: 0;
                margin-top: 0;
                position: unset !important;
            }
        }
    }

    @keyframes navbar-v-link-small {
        to {
            text-align: center;
            padding-left: 0px;
            padding-right: 0px;
        }
    }

    .navbar-v-item {
        > .navbar-v-link,
        > .navbar-v-dropdown > .navbar-v-link {
            animation: navbar-v-link-small forwards;
            animation-delay: 170ms;
            font-size: 0;
            transition: font-size 100ms ease-out;

            &:after {
                display: none;
            }
        }
    }

    .navbar-v-link, .navbar-v-dropdown-item {
        .navbar-dropdown-widget {
            display: none;
        }
    }

    .navbar-v-label {
        text-align: center;
    }
}

/* 垂直菜单 非折叠时的样式 */
.navbar-v-inline:not([data-collapse]),
.navbar-v-popout:not([data-collapse]) {
    overflow-y: auto;
    overflow-x: hidden;

    .navbar-v-dropdown {
        .navbar-v-dropdown-menu-container {
            position: relative;

            .navbar-v-dropdown-menu {
                position: relative !important;
                border: none;
                border-radius: 0;
                box-shadow: none;

                .navbar-v-dropdown-item {
                    padding: .5rem .5rem .5rem 3rem;
                }
            }
        }
    }

    .navbar-v-brand {
        .navbar-v-link {
            display: flex;
            align-items: center;
        }
    }
}

/* 垂直菜单 折叠隐藏模式 */
.navbar-v-inline[data-collapse=hide],
.navbar-v-popout[data-collapse=hide],
.navbar-v-small[data-collapse=hide] {
    width: 0px;
    min-width: 0px;
    overflow-y: hidden;

    &:not(.navbar-initial) {
        transition: width 200ms ease-in-out, min-width 200ms ease-in-out, visibility 100ms;
    }

    visibility: hidden;

    .navbar-v-toggler-inline {
        display: none;
    }

    .navbar-v-toggler-popout:not(.navbar-v-mobile-toggle) {
        visibility: visible;
        left: 0px;
    }
}

/* 垂直菜单 状态触发器 */
.navbar-v-inline:not(.navbar-rtl),
.navbar-v-popout:not(.navbar-rtl),
.navbar-v-small:not(.navbar-rtl) {
    .navbar-v-dropdown {
        .navbar-v-dropdown-toggle {
            &:before {
                @include navbar-v-dropdown-arrow;
                -webkit-transform: rotate(45deg);
                transform: rotate(45deg);
                top: 0.7rem;
                right: 1rem;
                float: right;
                border-width: 0 2px 2px 0;
            }

            .navbar-dropdown-widget {
                margin-right: 1.6rem;
            }
        }

        &:not([data-visible=true]) {
            .navbar-v-dropdown-toggle {
                &:before {
                    -webkit-transform: rotate(135deg);
                    transform: rotate(135deg);
                    top: 0.5rem;
                }
            }
        }
    }
}

/* 垂直菜单 状态触发器 */
.navbar-v-small:not(.navbar-rtl),
.navbar-v-inline[data-collapse=small]:not(.navbar-rtl),
.navbar-v-popout[data-collapse=small]:not(.navbar-rtl) {
    .navbar-v-dropdown {
        .navbar-v-dropdown-menu-container {
            .navbar-v-dropdown-menu {
                > .navbar-v-dropdown {
                    .navbar-v-dropdown-toggle {
                        &:before {
                            @include navbar-v-dropdown-arrow;
                            right: 1rem;
                            float: right;
                            border-width: 0 2px 2px 0;
                            -webkit-transform: rotate(315deg);
                            transform: rotate(315deg);
                        }
                    }

                    &:not([data-visible=true]) {
                        .navbar-v-dropdown-toggle {
                            &:before {
                                -webkit-transform: rotate(135deg);
                                transform: rotate(135deg);
                                right: 0.8rem;
                            }
                        }
                    }
                }
            }
        }
    }
}

/* 小屏设备 */
@media only screen and (max-width:576px) {
    .navbar-v-inline:not([data-collapse]) {
        min-width: 100vw;

        .navbar-v-toggler-inline:not(.navbar-v-mobile-toggle) {
            display: none;
        }

        .navbar-v-toggler-popout:not(.navbar-v-mobile-toggle) {
            left: 100vw;
        }

        .navbar-v-mobile-toggle {
            display: flex;
        }
    }
}

/* RTL模式 */
.navbar-rtl {
    direction: rtl !important;
    /* 滚动指示器 */
    .navbar-menu:after {
        border-right-width: 0;
        border-left: 2px solid #1890ff;
    }

    .navbar-v-toggler-inline {
        right: auto !important;
        left: 0 !important;
    }

    &.navbar-v-inline,
    &.navbar-v-popout,
    &.navbar-v-small {
        .navbar-v-dropdown {
            .navbar-v-dropdown-toggle {
                &:before {
                    @include navbar-v-dropdown-arrow;
                    -webkit-transform: rotate(315deg);
                    transform: rotate(315deg);
                    top: 0.7rem;
                    left: 1rem;
                    float: left;
                    border-width: 0 0 2px 2px;
                }

                .navbar-dropdown-widget {
                    margin-left: 1.6rem;
                }
            }

            &:not([data-visible=true]) {
                .navbar-v-dropdown-toggle {
                    &:before {
                        -webkit-transform: rotate(225deg);
                        transform: rotate(225deg);
                        top: 0.5rem;
                    }
                }
            }
        }

        .navbar-v-link {
            padding: .5rem 1.5rem .5rem .5rem;
        }

        .navbar-v-link, .navbar-v-dropdown-item {
            .navbar-dropdown-widget {
                float: left;
            }
        }
    }
    /* 垂直菜单 状态触发器 */
    &.navbar-v-small,
    &.navbar-v-inline[data-collapse=small],
    &.navbar-v-popout[data-collapse=small] {
        .navbar-v-dropdown {
            .navbar-v-dropdown-menu-container {
                .navbar-v-dropdown-menu {
                    > .navbar-v-dropdown {
                        .navbar-v-dropdown-toggle {
                            &:before {
                                @include navbar-v-dropdown-arrow;
                                left: 1rem;
                                float: left;
                                border-width: 0 0 2px 2px;
                                -webkit-transform: rotate(45deg);
                                transform: rotate(45deg);
                            }
                        }

                        &:not([data-visible=true]) {
                            .navbar-v-dropdown-toggle {
                                &:before {
                                    -webkit-transform: rotate(225deg);
                                    transform: rotate(225deg);
                                    left: 0.8rem;
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    .navbar-track {
        right: auto !important;
        left: 5px;
    }

    .dropdown-item {
        text-align: right !important;
    }

    &.navbar-h-topbar {
        .navbar-h-dropdown-menu {
            right: 100%;
            margin-left: .1rem !important;
            margin-right: 0 !important;
        }

        .nav-item.dropdown {
            > .navbar-h-dropdown-menu {
                right: 0px;

                &:after {
                    left: auto;
                    right: 18px !important;
                }
            }
        }

        .dropdown-item:after {
            -webkit-transform: rotate(90deg)!important;
            transform: rotate(90deg) !important;
            right: auto !important;
            left: 10%;
        }

        .dropdown .dropdown-toggle:after {
            margin-right: 6px;
            margin-left: auto !important;
        }
    }
}

.navbar-switch {
    height: 1.75rem;
    width: 1.75rem;
    background-color: var(--bs-gray-400);
    box-shadow: 0 0 0.5rem #211b50;

    &:hover {
        background-color: var(--bs-gray-600);
        box-shadow: 0 0 0.75rem #211b50;
    }
}

.glow {
    animation: glow 1200ms ease-out infinite alternate;

    @keyframes glow {
        0% {
            /*border-color: #393;*/
            box-shadow: 0 0 5px rgba(0, 255, 0, .1), inset 0 0 5px rgba(0, 255, 0, .1), 0 0px 0 #393;
        }

        100% {
            /*border-color: #393;*/
            box-shadow: 0 0 20px rgba(0, 255, 0, .5), inset 0 0 10px rgba(0, 255, 0, .2), 0 0 0 #393;
        }
    }
}
